package Exception;

import java.io.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-11-06
 * Time: 21:37
 */
class CustomExceptions extends Exception{
    public CustomExceptions(String str){
        super(str);
    }
}
public class Demo1 {
    public static void Func() {
        //在try()
        try(InputStream inputStream = new FileInputStream("C:/Program Files");){

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void Func1() throws IOException {
        InputStream inputStream = null;
        try{
            //这里相当于打开资源
            inputStream = new FileInputStream("C:/Program Files");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally{
            //关闭资源
            if(inputStream != null){
                inputStream.close();
            }
        }
    }
    public static void main(String[] args) throws FileNotFoundException {
        Func();
    }
}
